{include file="public/header" /}
<article class="page-container">
    <form action="" method="post" class="form form-horizontal" enctype="multipart/form-data" id="form-add">
        <div class="row cl">
            <label class="form-label col-xs-5 col-sm-5"><span class="c-red">*</span>商品名字：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="text" class="input-text" value="{$data.name|default=''}" placeholder="" id="name" name="name" readonly>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-5 col-sm-5"><span class="c-red">*</span>放单数量：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="number" class="input-text" style="width: 100%" placeholder="如果放单给用户，此数量为每个用户放单数量" id="num" name="num" autocomplete="off" >
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-10 col-sm-10"><span class="c-red">*</span>如果放单给用户，此数量为每个用户放单数量</label>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-5 col-sm-5"><span class="c-red">*</span>放单金额(金额为0 金额随机):</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="number" class="input-text" style="width: 100%" placeholder="如果放单给用户，此数量为每个用户放单数量" id="money" name="money" autocomplete="off" >
            </div>

        </div>
        <div class="row cl">
            <label class="form-label col-xs-5 col-sm-5"><span class="c-red">*</span>放单给谁：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <textarea type="text" class="input-text"  placeholder="请输入用户账号,多个用户用英文逗号分割" id="uids" name="uids" autocomplete="off" style="min-height: 100px"></textarea>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-10 col-sm-10 "><span class="c-red">*</span>如果为空则匹配虚拟用户,否则根据用户账号匹配用户</label>
        </div>


        <div class="row cl">
            <label class="form-label col-xs-5 col-sm-5"><span class="c-red">*</span>二级密码：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="password" class="input-text"  placeholder="" id="level_pass" name="level_pass" autocomplete="off">
            </div>
        </div>
        <div class="row cl">
            <div class="form-label col-xs-10 col-sm-10" style="text-align: center">
                <input type="hidden" value="{$data.id|default=''}" name="id">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>


{include file="public/footer" /}
<script type="text/javascript">
    $(function(){

        $("#form-add").validate({
            rules:{

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){

                var nextCommit = function () {
                    $(form).ajaxSubmit({
                        success:function(data){
                            console.log(data);
                            if(data.status == 0){
                                layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.location.reload();
                                    parent.layer.close(index);
                                });
                            }else{
                                layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                            }
                        },
                        error:function(error){
                            layer.msg('系统发生了错误',{icon:2,time:3000,shade: [0.5, '#FF0000']});
                        }
                    });
                }

                var num =Number($("#num").val());
                var uids =$("#uids").val();
                if (uids){
                    layer.confirm("您确定你输入的每个用户都发放"+num+"单，是否确认放单",function(index){
                        nextCommit()
                    });
                }else {
                    layer.confirm("一次性放单"+num+"给虚拟用户，是否确认放单",function(index){
                        nextCommit()
                    });
                }


            }
        });
    });
</script>
